namespace System.Xml.Serialization.Internal
{
    using System;
    using System.Xml;

    [Serializable]
    internal class XmlTypeSerializer : XmlTypeSettings
    {
        [NonSerialized]
        private readonly XmlReaderSettings _readerSettings = new XmlReaderSettings();
        [NonSerialized]
        private readonly XmlWriterSettings _writerSettings = new XmlWriterSettings();
        [NonSerialized]
        private XmlSerializer _serializer;

        internal XmlTypeSerializer(Type type) : base(type) { }

        internal override void CreateRuntimeSerializer(bool generateNew) { }
        internal override XmlSerializer InternalSerializer
        {
            get
            {
                if (_serializer == null)
                {
                    this._serializer = new XmlSerializer(this.RuntimeType);
                }
                return _serializer;
            }
        }
        internal override IXmlFormatAttributesInternal InternalAttributes { get { return null; } }
        internal override XmlReaderSettings InternalReaderSettings { get { return _readerSettings; } }
        internal override XmlWriterSettings InternalWriterSettings { get { return _writerSettings; } }
    }
}

